package com.hmall.item.config;

import lombok.Data;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2024/8/14 17:27
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "hm.es")
public class EsConfig {
    private String host;
    private String port;

    @Bean
    public RestHighLevelClient restHighLevelClient(){
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://" + host + ":" + port)
                /*new HttpHost(host, Integer.valueOf(port), "http")*/
        ));
    }
}
